package com.reremouse.service;

import com.reremouse.model.SystemEmailBoxModel;
import com.reremouse.rerebbs.dao.ISystemEmailBoxDAO;
import com.reremouse.util.SendEmail;
import com.reremouse.util.SpringHelper;

import java.io.Serializable;
import java.util.List;

public class EmailService
        implements Serializable {
    ISystemEmailBoxDAO esmss = (ISystemEmailBoxDAO) SpringHelper.getSpringBean("SystemEmailBoxDAO");

    public boolean sendEmail(String toEmail, String title, String content) {
        boolean ifs = false;
        List<SystemEmailBoxModel> es = this.esmss.findAllEmailBox();
        for (SystemEmailBoxModel e : es) {
            String host = e.getSmtpHost();
            String port = e.getSmtpPort();
            String urn = e.getSmtpUrn();
            String pwd = e.getSmtpPwd();
            String addr = e.getAddress();
            String alias = e.getAlias();
            boolean ssl = e.getSsl();
            boolean auth = e.getAuth();
            try {
                ifs = SendEmail.sendEmail("smtp", host, port, auth, ssl, urn, pwd, addr, alias, toEmail, title, content);
                if (ifs) {
                    break;
                }
            } catch (Exception ee) {
                ee.printStackTrace();
            }
        }
        return ifs;
    }
}



/* Location:           F:\jsp源码\蝙蝠论坛系统\rerebbs\WEB-INF\classes\

 * Qualified Name:     com.reremouse.service.EmailService

 * JD-Core Version:    0.7.0.1

 */